package com.genshang.restaurant.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.genshang.restaurant.entity.Accumulatelisttable;
import com.genshang.restaurant.mapper.AccumulatelisttableMapper;
import com.genshang.restaurant.service.IAccumulatelisttableService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类 用户积分表
 * </p>
 *
 * @author Alex
 * @since 2020-09-26
 */
@Service
public class AccumulatelisttableServiceImpl extends ServiceImpl<AccumulatelisttableMapper, Accumulatelisttable> implements IAccumulatelisttableService {

    @Override
    public Accumulatelisttable getCurrentByCustomerId(String customerId) {
        QueryWrapper<Accumulatelisttable> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("CUSTOMERID", customerId);
        queryWrapper.orderByDesc("CREATETIME");
        List<Accumulatelisttable> accumulatelisttableList = this.list(queryWrapper);
        if (CollectionUtils.isNotEmpty(accumulatelisttableList)) {
            return accumulatelisttableList.get(0);
        }
        return null;
    }
}
